<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/layui.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/view.css}"/>
    <link rel="icon" href="/favicon.ico">
    <title>管理后台-角色管理</title>
</head>
<body class="layui-view-body">
<div class="layui-content">
    <div class="layui-row">
        <div class="layui-card">
            <div class="layui-card-body">
                <button class="layui-btn layui-btn-blue"><i class="layui-icon">&#xe654;</i><a th:href="@{/a/role/form}">新增</a>
                </button>
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="200">
                        <col>
                    </colgroup>
                    <thead>
                    <tr>
                        <th>角色名</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="role:${roles}">
                        <td th:text="${role.name}">admin</td>
                        <td>
                            <a href="#" th:href="@{/a/role/form(id=${role.id})}" class="layui-btn layui-btn-sm">编辑</a>
                            <button class="layui-btn layui-btn-sm layui-btn-danger">启用</button>
                            <!--<button class="layui-btn layui-btn-sm layui-btn-danger" onclick="loadMenu()">授权</button>-->
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!--分页导航-->
                <div id="pagination"></div>
                <!--加载菜单数据-->
                <div class="show-menu-data" style="display: none;padding: 10px">
                    <form class="layui-form">
                        <div id="menuTree" class="xtree_contianer"></div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
<script th:src="@{/assets/layui.all.js}"></script>
<script th:inline="javascript">
    /*<![CDATA[*/
    var count = [[${count}]];//总记录数
    var curr = [[${curr}]];//当前页
    var contextPath = [[${#request.getContextPath()}]]; //获取当前应用路径
    /*]]>*/
</script>
<script type="text/javascript">
    layui.use('laypage', function () {
        var laypage = layui.laypage;

        //执行一个laypage实例
        laypage.render({
            elem: 'pagination' //注意，这里的 data 是 ID，不用加 # 号
            , count: count //数据总数，从服务端得到
            , curr: curr
            , limit: 5
            , jump: function (obj, first) {
                //obj包含了当前分页的所有参数，比如：
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数

                //首次不执行
                if (!first) {
                    window.location.href = contextPath + "/a/role/list?page=" + (obj.curr) + "&size=" + obj.limit
                }
            }
        });
    });
</script>
</body>
</html>